package com.wanbangee.marksystem.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wanbangee.marksystem.entities.MSubject;
import com.wanbangee.marksystem.service.TopScoreCompositionService;

@RestController
public class TopScoreCompositionController {
	
	@Autowired
	private TopScoreCompositionService topScoreCompositionService;
	
	/**
	 * 根据所选择的考试查询考试科目为语文和英语的考试
	 * @param subId
	 * @param examId
	 * @return
	 */
	@GetMapping("/topScoreComposition/selectMSubjectByExamId")
	public Map<String, Object> selectMSubjectByExamId(Integer examId){
		//用来存储提示信息，和状态码，数据
		Map<String, Object> responseMap = new HashMap<String, Object>();
		
		//调用scoreAndAnswerSheetService中selectScoreSubsectionByExamIdAndSubId方法查询分数段指标表
		List<MSubject> msts = topScoreCompositionService.selectMSubjectByExamId(examId);
		
		if(msts == null || msts.size() == 0) {  //查询失败
			responseMap.put("code", 10013);
			responseMap.put("msg", "该考试不包含有作文的科目考试");
		}else {
			//将查询到的科目信息放入map中返回给前端
			responseMap.put("msts", msts);
			//返回状态码1001，提示信息：接口成功
			responseMap.put("code", 1001);
			responseMap.put("msg", "接口成功");
		}
		return responseMap;
	}
}
